<?php
class model_lottery extends base_model{
	public $game_id = 1;		// 彩票种类ID
	public $group_id = 6;		// 玩法组ID
	public $play_id = 37;		// 玩法ID
	public $actionNumber = '';	// 期号
	public $gameFanDian = 0;
	private $result = array(
		'state' => 404,
		'message' => 'error',
	);
	public function __construct() {
		//默认不用登录
		//$this->usercheck = false;
		parent::__construct();
	}
	//当前彩种是否开启
	public function mod_exits_open($id){
		$sql="select enable,title from @@lottery_type where id={$id} LIMIT 1";
		$data = $this->db->query($sql,2);
		return array(
			'enable' => intval($data['enable']),
			'title' => $row['title'].($data['enable']?'':'已经关闭'),
		);
	}
	//取出玩法名称
	public function mod_group_name($id){
		$sql="select groupName from @@lottery_played_group where id={$id} LIMIT 1";
		$data=$this->db->query($sql,2);
		return $data['groupName'];
	}
	//玩法本当前说明
	public function mod_played_info($groupId){
		$sql="select simpleInfo, info, example  from @@lottery_played where enable=1 and groupId={$groupId} order by sort LIMIT 1";
		$data=$this->db->query($sql,2);
		return $data;
	}
	//取出所有玩法
	public function mod_playeds($groupId){
		$sql="select id, name, playedTpl, enable  from @@lottery_played where enable=1 and groupId={$groupId} order by sort LIMIT 1";
		$data=$this->db->query($sql,2);
		return $data;
	}
	//取出用户的当前余额
	public function mod_user_coin(){
		return $this->user['coin'];
	}
	/*
	取出首页的轮播广告
	*/
	public function mod_banner($typeid=12){
		$sql = "SELECT `id`,`icon`,`title`,`url` FROM `@@attachments` WHERE `category`={$typeid} AND `state`=1";
		$data = $this->db->query($sql,3);
		return $data;
	}
	/*
	取出彩种
	0 => 所有
	1 => 高频
	2 => 底频
	3 => 体育
	4 => 福彩
	5 => 自定义
	*/
	public function mod_lottery_type($type=0){
		$sql = "SELECT `id`,`type`,`name`,`title`,`shortName`,`num`,`info` FROM `@@lottery_type` WHERE `enable`=1";
		$data = $this->db->query($sql,3);
		return $data;
	}
}